import functools


def do_reduce(a, b):
    print('do_reduce({}, {})'.format(a, b))
    return a + b


print('single item in sequence: ',
      functools.reduce(do_reduce, [1]))

print('single item in sequence with initializer: ',
      functools.reduce(do_reduce, [1], 99))

print('empty sequence with initializer: ',
      functools.reduce(do_reduce, [], 99))

try:
    print('empty sequence: ', functools.reduce(do_reduce, []))
except TypeError as err:
    print(('ERROR: {}'.format(err)))
